<template>
  <div class="page">
    <div class="title">营销指引管理</div>
    <div class="searchContent">
      <div class="inputContent">
        <ui-form class="query-form" :model="queryForm" label-width="140px">
          <ui-form-item label="指引编号">
            <ui-input type="text" placeholder="请输入指引编号" v-model="queryForm.pointNum"> </ui-input>
          </ui-form-item>
          <ui-form-item label="创建人">
            <ui-input type="text" placeholder="请输入创建人" v-model="queryForm.createPerson"> </ui-input>
          </ui-form-item>
          <ui-form-item label="创建机构">
            <ui-select placeholder="请选择创建机构" v-model="queryForm.createOrigan">
              <ui-option v-for="(item, index) in organList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="创建日期">
            <ui-date-picker v-model="queryForm.createTime" type="date" placeholder="选择创建日期" style="width: 300px"> </ui-date-picker>
          </ui-form-item>
        </ui-form>
      </div>
      <div class="searchButton">
        <ui-button class="default-btn reset" @click="reset">重置</ui-button>
        <ui-button class="primary-btn" @click="search">查询</ui-button>
      </div>
    </div>
    <div class="tableContent">
      <div class="name">
        <span>营销指引列表</span>
        <ui-button class="primary-btn" @click="addMarketingPoint">新增</ui-button>
      </div>
      <vx-nodata :list="tableData" v-loading="isLoading" sub-title="暂无数据">
        <vx-table-slot :tableData="tableData" :columns="columns">
          <template #action="{ scope }">
            <ui-button type="text" @click="handleUpdate(scope.row)">修改 </ui-button>
            <ui-button type="text" @click="handleDelete(scope.row)">删除</ui-button>
          </template>
          <template #pointNum="{ scope }">
            <div @click="toDetail(scope.row)" class="pointNum">{{ scope.row.pointNum }}</div>
          </template>
        </vx-table-slot>
        <ui-pagination
          :total="total"
          :page-size="pageSize"
          :current-page="currentPage"
          :layout="layout"
          :page-sizes="pageSizeList"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        >
        </ui-pagination>
      </vx-nodata>
    </div>
  </div>
</template>

<script>
import pagination from '@/common/mixin/pagination.js'; // 混入/分页
import vxTableSlot from '@/components/vx-table-slot';
export default {
  name: 'myCustom',
  mixins: [pagination],
  components: {
    vxTableSlot,
  },
  data() {
    return {
      queryForm: {},
      organList: [
        { id: 1, name: '全部' },
        { id: 2, name: '类型一' },
        { id: 3, name: '类型二' },
      ],
      tableData: [
        { pointNum: '1111111111', pointContent: 'AAAAAAAA', remark: 'qqqqqq' },
        { pointNum: '222222222222222', pointContent: 'BBBBBBB', remark: 'wwwww' },
        { pointNum: '333333', pointContent: 'CCCCCCCC', remark: 'eeeee' },
      ],
      columns: [
        {
          label: '序号',
          prop: 'financialAssets',
          formatter: (row, column, cellValue, index) => {
            return index + 1;
          },
        },
        {
          label: '指引编号',
          prop: 'pointNum',
          slots: { name: 'pointNum' },
        },
        {
          label: '指引内容',
          prop: 'pointContent',
        },
        {
          label: '备注',
          prop: 'remark',
        },
        {
          label: '创建日期',
          prop: 'createTime',
        },
        {
          label: '创建人',
          prop: 'createPerson',
        },
        {
          label: '创建机构',
          prop: 'createOrigan',
        },
        {
          label: '操作',
          prop: 'slot',
          slots: { name: 'action' },
          width: '200',
        },
      ],
      customSelection: [],
      isLoading: false,
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    searchList() {},
    getCustomLevel(e) {},
    search() {
      this.pageNum = 1;
      this.searchList();
    },
    reset() {
      this.queryForm.pointNum = undefined;
      this.queryForm.manageType = undefined;
      this.queryForm.customLevel = undefined;
      this.queryForm.customType = undefined;
      this.searchList();
    },
    addMarketingPoint() {
      this.$router.push({
        path: '/marketingManager/marketingPointManager/marketingPointEdit',
        query: {
          type: 'add',
        },
      });
    },
    handleUpdate(row) {
      this.$router.push({
        path: '/marketingManager/marketingPointManager/marketingPointEdit',
        query: {
          type: 'edit',
          marketPonintInfo: JSON.stringify(row),
        },
      });
    },
    async handleDelete() {
      this.$confirm('请确认是否删除该营销指引?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error',
      }).then(async () => {
        // const res = await roleApi.roleRemove({ ids: id });
        // this.$message.success(res.msg);
        // this.searchList();
      });
    },
    toDetail(row) {
      this.$router.push({
        path: '/marketingManager/marketingPointManager/marketingPointDetail',
        query: {
          marketPonintInfo: JSON.stringify(row),
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  .title {
    font-size: 18px;
    color: #000;
    font-weight: bold;
  }
  .searchContent {
    background: #fff;
    padding: 20px 20px 0 0;
    margin-top: 10px;
    .inputContent {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding: 10px;
      // border-bottom: 1px solid #ccc;
      ::v-deep .ui-input {
        width: 190px !important;
      }
      ::v-deep .query-form .ui-form-item {
        width: 23% !important;
      }
    }
    .searchButton {
      padding: 10px 10px 10px 10px;
      display: flex;
      justify-content: right;
      align-items: center;
      .reset {
        border-color: #5085f9;
        color: #5085f9;
      }
    }
  }
  .tableContent {
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    .name {
      span {
        font-size: 14px;
        color: #000;
        font-weight: bold;
      }

      margin-bottom: 20px;

      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .concern {
      background: #fff;
      border-color: orange;
      color: orange;
      font-size: 14px;
    }
    .alreayConcern {
      background: #fff;
      border-color: #ccc;
      font-size: 14px;
    }
    .footerButton {
      border-top: 1px solid #ccc;
      margin-top: 20px;
      padding: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
.query-form {
  display: flex;
  flex-wrap: wrap;
}
.pointNum {
  color: #5085f9;
  cursor: pointer;
}

::v-deep .ui-date-editor--date .ui-input__prefix {
  left: 5px !important;
}
::v-deep .ui-date-editor--date .ui-input__inner {
  padding-left: 40px !important;
}
</style>
